package com.gxa.service.investment.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gxa.dto.investmentDto.CompanyDto;
import com.gxa.entity.investment.Company;
import com.gxa.mapper.investment.CompanyMapper;
import com.gxa.service.investment.CompanyService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxa.vo.investmentVo.ProjectCloseVo;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * <p>
 * 企业表 服务实现类
 * </p>
 *
 * @author yjl
 * @since 2022-10-16 11:39:46
 */
@Service
public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> implements CompanyService {

    @Autowired
    private CompanyMapper companyMapper;

    @Override
    public int add(Company company) {
        Date date = new Date();
        company.setStartDate(date);
        return companyMapper.insert(company);
    }

    @Override
    public int delete(Integer id) {
        return companyMapper.deleteById(id);
    }

    @Override
    public Company queryById(Integer id) {
        return companyMapper.queryById(id);
    }

    @Override
    public List<Company> seletAll() {
        return companyMapper.selectList(null);
    }

    @Override
    public int update(Company company) {
        return companyMapper.updateById(company);
    }

    @Override
    public PageInfo<Company> queryByCompanyDto(CompanyDto companyDto,Integer pageNum, Integer pageSize) {
        Page<Company> page = PageHelper.startPage(pageNum,pageSize);
        List<Company> companyList = this.companyMapper.queryByCompanyDto(companyDto);
        PageInfo<Company> pageInfo = new PageInfo<>(companyList);

        return pageInfo;
    }
}
